package com.amiu.shiro.db.permission;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface PermissionDao {
	public Permission createPermission(Permission permission);  
	
	@Delete("DELETE from permission where id=#{id}")
    public void deletePermission(Long id);  
	
	public void updatePremission(Long id);
	@Select("SELECT id,name,address,code,icon,pid,seq,create_time FROM permission WHERE id=#{id}")
	public Permission findById(Long id);
	
	@MapKey("id")
	@Select("SELECT id,name,address,code,icon,pid,seq,create_time FROM permission")
	public Map<Long,Permission>  findAll();
	
	@MapKey("id")
	@Select("SELECT id,name,address,code,icon,pid,seq,create_time FROM permission WHERE pid=#{pid}")
	public Map<Long,Permission> findSonId(Long pid);
	
	@MapKey("id")
	public Map<Long,Permission> findByRoleId(@Param("roleIds")List<Long> roleIds);
	
	@MapKey("id")
	public Map<Long,Permission> findByIds(@Param("ids")List<Long> ids);
}
